package com.example.demos.web.controller;

import com.example.demos.dto.EmpAccessDTO;
import com.example.demos.service.ResetPassWordService;
import com.example.demos.util.PageBean;
import com.example.demos.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

@RestController
@RequestMapping("/v2")
public class ResetPassWordController {
    @Autowired
    ResetPassWordService resetPassWordService ;

    @GetMapping("/emp_listByPage/listByPage")
    Result<PageBean<List<EmpAccessDTO>>> getEmpAccess(Integer page,Integer rows){
      return  Result.ok(resetPassWordService.getEmpAccess(page,rows));
    }
    @PostMapping("/emp_updatePwd_reset/update")
    Result<Void> resetPassWord(BigInteger id,String newPwd){
        if(resetPassWordService.resetPwd(id,newPwd)){
            return Result.ok("重置密码成功");
        }
            return Result.bizErr("新密码格式有误，修改失败。");
    }
}
